﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.lmpop.trade.tb_ordergoods.*"%>
<%@ page import="com.lmpop.trade.ti_orderinfo.*"%>
<%@ page import="com.lmpop.trade.shopcart.*"%>
<%@ page import="java.util.*,com.lmpop.frame.SysMap" %>
<%@ page import="com.lmpop.trade.tb_ordergoods.Tb_ordergoodsInfo" %>
<%@page import="java.text.DecimalFormat"%>
<%
	request.setCharacterEncoding("UTF-8");
	CartServices shopcart = null;
	if(session.getAttribute("shoppingCart") != null){
		shopcart = (CartServices)session.getAttribute("shoppingCart");
		shopcart.clear();
	}
	
	String trade_no = "";
	if(request.getParameter("trade_no")!=null){
		trade_no = request.getParameter("trade_no");
	}
	 String gotoOnlinePay = "";
	if(request.getParameter("gotoOnlinePay")!=null){
		gotoOnlinePay = request.getParameter("gotoOnlinePay");
	}
	
	String subject="";
	if(request.getParameter("subject")!=null){
		subject = request.getParameter("subject");
	}
	
	String shipingfeetotal="";
	if(request.getParameter("shipingfeetotal")!=null){
		shipingfeetotal = request.getParameter("shipingfeetotal");
	}
	
	Tb_ordergoodsInfo tb_ordergoodsInfo =new Tb_ordergoodsInfo();
	Ti_orderinfoInfo ti_orderinfo = new Ti_orderinfoInfo();

	List  orderList =  null;
	
	String all_total_amount="";
	if(request.getParameter("all_total_amount")!=null){
		all_total_amount = request.getParameter("all_total_amount");
	}
	String all_voucher_money="";
	if(request.getParameter("all_voucher_money")!=null){
		all_voucher_money = request.getParameter("all_voucher_money");
	}
	
	String shipping_name="";
	if(request.getParameter("shipping_name")!=null){
		shipping_name = request.getParameter("shipping_name");
	}
	String payment_name="";
	if(request.getParameter("pay_name")!=null){
		payment_name = request.getParameter("pay_name");
	}

	DecimalFormat df = new DecimalFormat("####.00");
	String out_trade_no =  trade_no;	//请与贵网站订单系统中的唯一订单号匹配
	String price = all_total_amount;						//订单总金额，显示在支付宝收银台里的“商品单价”里

	//String voucher_price="";
	//String logistics_fee = shipingfeetotal;				//物流费用，即运费。
//	String subject = "订单:"+out_trade_no;//request.getParameter("subject");//订单名称，显示在支付宝收银台里的“商品名称”里，显示在支付宝的交易管理的“商品名称”的列表里。
	String body = "订单:"+out_trade_no;	//request.getParameter("body");//订单描述、订单详细、订单备注，显示在支付宝收银台里的“商品描述”里
	String logistics_type = "EXPRESS";	//request.getParameter("logistics_type");//物流类型，三个值可选：EXPRESS（快递）、POST（平邮）、EMS（EMS）
	String logistics_payment ="BUYER_PAY"; request.getParameter("logistics_payment");//物流支付方式，两个值可选：SELLER_PAY（卖家承担运费）、BUYER_PAY（买家承担运费）
	String quantity = "1";				//商品数量，建议默认为1，不改变值，把一次交易看成是一次下订单而非购买一件商品。
	String receive_name = "";			//收货人姓名，如：张三
	String receive_address = "";		//收货人地址，如：XX省XXX市XXX区XXX路XXX小区XXX栋XXX单元XXX号
	String receive_zip = "";			//收货人邮编，如：123456
	String receive_phone = "";			//收货人电话号码，如：0571-81234567
	String receive_mobile = "";			//收货人手机号码，如：13312341234
//	String shipping_name = "";	
	String payment_id = "";	
	//String payment_name = "";	
	String order_state = "";
	double all_price =0;
	double all_logistics_fee =0;
	String order_no="";
	double temp_price=0.00;
	if(all_voucher_money!=null&&!"".equals(all_voucher_money)){
		temp_price=Double.parseDouble(price)-Double.parseDouble(all_voucher_money);
		if(temp_price>0){
			price=String.valueOf(df.format(temp_price));
		}
		else
			price="0.00";
   }
	
	if(gotoOnlinePay.equals("1")){
		receive_name ="order_no";
		orderList = ti_orderinfo.getOrderInfoByNO(trade_no);
	} else{
		receive_name ="trade_no";
		orderList = ti_orderinfo.getOrderInfoByID(trade_no);
	}
	//获得订单号
	if(orderList!=null && orderList.size()>0){
		HashMap map = (HashMap)orderList.get(0);
		order_no = map.get("order_no").toString();
	}
	
	String user_id = "",user_email = "";	
	if( session.getAttribute("session_user_id") != null ){
		user_id = session.getAttribute("session_user_id").toString();
		user_email = "";
	}	

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>订单成功页面</title>
<link href="/templets/html/shop/css/mall_top.css" rel="stylesheet" type="text/css" />
<link href="/templets/html/shop/css/dd_qr.css" rel="stylesheet" type="text/css" />
<link href="/templets/html/shop/css/mall_bottom.css" rel="stylesheet" type="text/css" />
<link href="/templets/html/shop/css/style.css" rel="stylesheet" type="text/css" />
<link  href="/templets/html/shop/css/Home.css" rel="stylesheet"/>
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/templets/html/shop/js/ShopOrder.js"></script>
<SCRIPT src="/templets/html/shop/js/taobao.js"></SCRIPT>
<SCRIPT src="/templets/html/shop/js/nav_style_num.js"></SCRIPT>
<script type='text/javascript' src='/dwr/engine.js'></script>
<script type='text/javascript' src='/dwr/util.js'></script>
<script type='text/javascript' src='/dwr/interface/Ti_subscribeInfo.js'></script>
<script type='text/javascript' src='/templets/html/shop/js/_shop.js'></script>
<style type="text/css">
	.STYLE1 {color: #FFFFFF}
</style>
</head>
<body>
<%
	if(!gotoOnlinePay.equals("1")){
%>
<div class="clearfix">
  <!--导航开始-->
  <div>
    <div>
      <script> 
  document.write("<s" + "cript type='text/javascript' src='/templets/html/shop/top.jsp?" + Math.random() + "'></scr" + "ipt>");
  TB.Header.init();  
</script>
    </div>
    <!--导航结束-->
    <div class="clear"></div>
    <!--收获信息结束-->
    <form id="paysubmit" name="paysubmit" action="" method="post" >
      <input type="hidden" name="out_trade_no" value="<%= trade_no%> "/>
      <input type="hidden" name="subject" value="<%=subject%>"/>
      <input type="hidden" name="body" value="<%=body%> "/>
      <input type="hidden" id="price" name="price" value="<%=price%>"/>
      <input type="hidden" name="logistics_fee" value="<%=shipingfeetotal%> "/>
      <input type="hidden" name="logistics_type" value="<%=logistics_type%> "/>
      <input type="hidden" name="logistics_payment" value="<%=logistics_payment%> "/>
      <input type="hidden" name="quantity" value="<%=quantity%> "/>
      <input type="hidden" name="receive_name" value="<%=receive_name%> "/>
      <input type="hidden" name="receive_address" value="<%=receive_address%> "/>
      <input type="hidden" name="receive_zip" value="<%=receive_zip%> "/>
      <input type="hidden" name="receive_phone" value="<%=receive_phone%> "/>
      <input type="hidden" name="receive_mobile" value="<%=receive_mobile%>"/>
      <input type="hidden" name="user_id" id="user_id" value="<%=user_id%>"/>
      <input type="hidden" name="user_email" id="user_email" value="<%=user_email%>"/>
    </form>
    <div class="content0">
      <div class="chengxu">
        <div class="chengxu_m">
          <ul>
            <li class="txt_li">登录/注册<small>login/regist</small><img align="absmiddle" src="/templets/html/shop/images/jiantou.gif" /></li>
            <li class="txt_li">我的购物车<small>shopping cart</small><img align="absmiddle" src="/templets/html/shop/images/jiantou.gif" /></li>
            <li class="txt_li">填写订单信息<small>order information</small><img align="absmiddle" src="/templets/html/shop/images/jiantou_l.gif" /></li>
            <li class="tex_current">提交订单,付款<small>submit/pay</small><img align="absmiddle"src="/templets/html/shop/images/jiantou_r.gif" /></li>
            <li class="txt_li">等待收货<small>wait for delivery</small></li>
          </ul>
        </div>
      </div>
      <div><img src="/templets/html/shop/images/dd_18.gif" style=" margin-top:8px" /></div>
      <DIV class=tjk>
        <UL>
          <LI class=tj>
            <%
			if(!payment_id.equals("0")){
		%>
            订单已提交，请尽快付款！
            <%
			}else{
		%>
            订单已提交，我们会尽快安排发货！
            <%
			}
		%>
          </LI>
          <LI class=zdh>
            <!--您的账单号：<b></b>&nbsp;&nbsp;&nbsp;&nbsp;-->
            应付实款：<B><%=price%></B>元&nbsp;&nbsp;&nbsp;&nbsp;
            支付方式：<%=payment_name%>&nbsp;&nbsp;&nbsp;&nbsp;
            配送方式：<%=shipping_name%>
            <%
			if(!payment_id.equals("0")){
		%>
          </LI>
          <LI class=zf>还差一步，请立即支付!</li>
          <LI class=zf_an> <a href="####" onclick="submitOrderForm('<%=payment_id.trim()%>');"><img src="/templets/html/shop/images/dd_23.jpg" /></a> </li>
          <%
			} else{
		%>
          <li class="zf">您选择了货到付款，等待卖家发货！</li>
          <%
			}	
		%>
          <LI>完成支付后，您可以： <A href="orderdetail.jsp?order_no=<%=order_no%>">查看订单状态</A>&nbsp;&nbsp;&nbsp;&nbsp; <A href="/data/shop.html">继续购物</A>&nbsp;&nbsp;&nbsp;&nbsp;
            <!--<A href="/templets/html/default/b2c/jsp/help_detailed.jsp?info_id=A4MRaM7833OML12">反馈建议</A>&nbsp;&nbsp;&nbsp;&nbsp;-->
          </LI>
        </UL>
      </DIV>
      <P><IMG src="/templets/html/shop/images/dd_19.gif"></P>
    </DIV>
    <!--提交框结束-->
    <!--广告开始-->
  </div>
  <!--广告开始-->
  <div class="commitment">
    <div class="commitment_left">
      <div class="commitment_pic"><a href=""><img src="/templets/html/shop/images/commitment_1.jpg" /></a></div>
      <div class="commitment_txt">
        <p><span class="commitment_txt1">全国900个城市货到付款</span><span class="commitment_txt2"><a href=""></a></span></p>
      </div>
    </div>
    <div class="commitment_center">
      <div class="commitment_pic"><a href=""><img src="/templets/html/shop/images/commitment_2.jpg" /></a></div>
      <div class="commitment_txt3">
        <p><span class="commitment_txt1">购买满200免运费</span><span class="commitment_txt2"><a href=""></a></span></p>
      </div>
    </div>
    <div class="commitment_right">
      <div class="commitment_pic"><a href=""><img src="/templets/html/shop/images/commitment_3.jpg" /></a></div>
      <div class="commitment_txt4">
        <p><span class="commitment_txt1">30天无忧退换货保障</span><span class="commitment_txt2"><a href=""></a></span><span class="commitment_txt1"></span></p>
      </div>
    </div>
  </div>
  <!--广告结束-->
  <div class="clear"></div>
  <!--底部开始-->
  <jsp:include page="/templets/html/shop/footer.jsp"/>
  <!--底部结束-->
</div>
<%
			} else{
		%>
<script>
			//submitOrderForm("<%=payment_id.trim()%>");
			</script>
<%
			}
		%>

</body>
</html>
